var ValidateForm = new Class({
	initialize: function (form, options){
	
		$(form).addEvent('submit', function (e){
			if(this.hasAttribute("valid") && !this.valid) this.submit();
		})
	
	
		// opts de base
		var defOpts = {
			onElementValidate: function(isValid, field, className, warn){
				
			},
			onElementFail: function (field, validatorsFailed){
				//console.log(field, validatorsFailed)
			},
			useTitles: true,
			scrollToErrorsOnSubmit: false,
			evaluateOnSubmit: true,
			evaluateFieldsOnBlur: false,
			evaluateFieldsOnChange: false,
			serial: false
		}
		
		// modif opts
		for(var o in options){
			defOpts[o] = options[o];
		}
		
		// instance
		new FormValidator.Inline(form, defOpts);
	}
});
Moodule.register("ValidateForm", "form.toValidate");
Moodule.register("ValidateForm", "form.toValidateOnBlur", {evaluateFieldsOnBlur:true});
Moodule.register("ValidateForm", "form.toValidateInstant", {evaluateFieldsOnBlur:true, evaluateFieldsOnChange: true});
Moodule.register("ValidateForm", "form.toValidateParcours", {
	evaluateFieldsOnBlur:true, 
	evaluateFieldsOnChange: true,
	onFormValidate: function(isValid, form, event){
		if(isValid) cleanForm(form);
	}
});
Moodule.register("ValidateForm", "form.toValidateLayerPnm",{
	onFormValidate: function(isValid, form, event){
		if (isValid) {
			redirectLayerPnm();
			event.preventDefault();
		}
	}
});
